package collections;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class HashMapTest {

	public static void main(String args[]) {
		HashMap hm = new HashMap();
		hm.put("one", "zhangsan");
		hm.put("two", "lisi");
		hm.put("three", "wangwu");
		
		System.out.println(hm.get("one"));
		System.out.println(hm.get("two"));
		System.out.println(hm.get("three"));
		
		Set keys = hm.keySet();
		System.out.println("Keys:");
		ArrayListTest.printElement(keys);
		
		Collection values = hm.values();
		System.out.println("Values:");
		ArrayListTest.printElement(values);
		
		Set entry = hm.entrySet();
		ArrayListTest.printElement(entry);
		Iterator it = entry.iterator();
		while(it.hasNext())
		{
			Map.Entry me = (Map.Entry)it.next();
			System.out.println("key:"+me.getKey()+" value:"+me.getValue());
		}
	}
}
